<!--
 * @Descripttion: 
 * @Author: voanit
 * @Date: 2022-08-26 18:01:48
 * @LastEditors: voanit
 * @LastEditTime: 2022-08-26 18:10:29
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const obj = {
      func: function () { }, //丢失
      n: null,
      reg: /^\d+$/,//丢失
      under: undefined  //丢失
    }
    const newObj = JSON.parse(JSON.stringify(obj))
    console.log(newObj);
    /*
    关于深拷贝和浅拷贝面试题 如何回复
    1-什么是深拷贝和浅拷贝
    2-实现深拷贝和浅拷贝有哪些方法
      深拷贝：JSON.parse(JSON.stringify())+递归+cloneDeep()
      浅拷贝:赋值+[...arr]+Object.assign()
    3-缺陷：如上 会出现函数拷贝丢失
    4-场景：在哪里用
    */
  </script>
</body>

</html>